<?php

namespace App\Transformers;

use App\Models\RecordRemark;
use League\Fractal\TransformerAbstract;

class RecordRemarkTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['record','user'];


    public function transform(RecordRemark $recordRemark)
    {
        return [
            'id' => $recordRemark->id,
            'status' => $recordRemark->status,
            'record_id' => empty($recordRemark->record_id)?'':$recordRemark->record_id,
            'user_id' => empty($recordRemark->user_id)?'':$recordRemark->user_id,
            'created_at' => empty($recordRemark->created_at)?'':$recordRemark->created_at->toDateTimeString(),
            'updated_at' => empty($recordRemark->updated_at)?'':$recordRemark->updated_at->toDateTimeString(),
        ];
    }

    public function includeUser(RecordRemark $recordRemark)
    {
        return $this->item($recordRemark->user, new UserTransformer());
    }

    public function includeRecord(RecordRemark $recordRemark)
    {
        return $this->item($recordRemark->record, new PhoneRecordTransformer());
    }
}